home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / s / saveprefs.pprx < prev    next >
Text File  |  1993-02-01  |  7KB  |  257 lines

  1. /*
  2. @BSavePrefs  @P@ICopyright Gold Disk Inc., January, 1992
  3.  
  4. This Genie will save any settings in the current PPage environment to a config file. Professional Page will then always start up with your specified settings. (Example: Magnification, Colormode, Interlace, etc...) 
  5.  
  6. */
  7. address command
  8. call SafeEndEdit.rexx()
  9.  
  10. cr  = '0a'x
  11. startclip   = "/*****Start Clips*****/"
  12. endclip     = "/*****End Clips*****/"
  13. startprefs  = "/*****Start Prefs*****/"
  14. endprefs    = "/*****End Prefs*****/"
  15. startsave   = "/*****StartSave*****/"
  16. endsave     = "/*****EndSave*******/"
  17. startupfile = "s:ppage.config"
  18. styletagdef    = "s:styletags.dflt"
  19. paratagdef    = "s:paratags.dflt"
  20. startup     = ''
  21. clist       = 0
  22.  
  23. selection   = "AngleStep"
  24. selection   = selection || cr"BaseLine"
  25. selection   = selection || cr"BoxOutlines"
  26. selection   = selection || cr"ColorMode"
  27. selection   = selection || cr"Columns"
  28. selection   = selection || cr"DateFormat"
  29. selection   = selection || cr"DitherMode"
  30. selection   = selection || cr"FillColor"
  31. selection   = selection || cr"FillPattern"
  32. selection   = selection || cr"Font"
  33. selection   = selection || cr"Grid"
  34. selection   = selection || cr"GridSize"
  35. selection   = selection || cr"GridSnap"
  36. selection   = selection || cr"Hyphenation"
  37. selection   = selection || cr"HyphenControl"
  38. selection   = selection || cr"HyphenLang"
  39. selection   = selection || cr"Interrupt"
  40. selection   = selection || cr"Justification"
  41. selection   = selection || cr"Kerning"
  42. selection   = selection || cr"LineColor"
  43. selection   = selection || cr"LinePattern"
  44. selection   = selection || cr"LineSpacing"
  45. selection   = selection || cr"LineWeight"
  46. selection   = selection || cr"MagMode"
  47. selection   = selection || cr"PageNumFormat"
  48. selection   = selection || cr"ParaTag"
  49. selection   = selection || cr"QuickMove"
  50. selection   = selection || cr"RulerType"
  51. selection   = selection || cr"Size"
  52. selection   = selection || cr"Style"
  53. selection   = selection || cr"StyleTag"
  54. selection   = selection || cr"TextColor"
  55. selection   = selection || cr"TextGreek"
  56. selection   = selection || cr"TextFilter"
  57. selection   = selection || cr"Tracking"
  58. selection   = selection || cr"Units"
  59. selection   = selection || cr"WireFrame"
  60. selection   = selection || cr"Workbench"
  61.  
  62. counter = 1
  63.  
  64. special = "TEXTCOLOR TEXTFILTER FONT LINECOLOR FILLCOLOR PARATAG STYLETAG"
  65.  
  66. /*  if exists then read file into line array and separate sections  */
  67. if ~exists(startupfile) then
  68. do
  69.     startup = "/*"cr || '09'x || "Professional Page Configuration File"cr"*/"
  70.  
  71.     entry   = "In order to facilitate automated address entry using Page Genies, Professional Pages stores personal information in a configuration file. Would you like to fill out the info form?"
  72.  
  73.     if ppm_Inform(2, entry,"No","Yes") then
  74.     do
  75.  
  76.         form    = "Name"cr"Company Name"cr"Address"cr"City"cr"State/Province"cr"Country"cr"Zip/Postal Code"cr"Phone"cr"Fax"
  77.  
  78.         form    = ppm_GetForm("Information Form", 35, form)
  79.         if form = '' then exit_msg()
  80.  
  81.         parse var form name '0a'x comp '0a'x add '0a'x city '0a'x state '0a'x country '0a'x zc '0a'x phone '0a'x fax
  82.  
  83.         prefix  = "call setclip(ppuser_"
  84.  
  85.         clips.1 = startclip
  86.         clips.2 = prefix || 'name,"'name'")'
  87.         clips.3 = prefix || 'company,"'comp'")'
  88.         clips.4 = prefix || 'address,"'add'")'
  89.         clips.5 = prefix || 'phone,"'phone'")'
  90.         clips.6 = prefix || 'zipcode,"'zc'")'
  91.         clips.7 = prefix || 'city,"'city'")'
  92.         clips.8 = prefix || 'state,"'state'")'
  93.         clips.9 = prefix || 'country,"'country'")'
  94.         clips.10 = prefix || 'fax,"'fax'")'
  95.         clips.11= endclip
  96.         clist   = 11
  97.  
  98.     end
  99.  
  100. end
  101. else
  102. do
  103.  
  104.     if ~open(file, startupfile, "r") then
  105.         call exit_msg("DOS error. Unable to create a configuration file.")
  106.  
  107.     do while ~eof(file)
  108.  
  109.         text = strip(readln(file))
  110.         if text = '' then iterate
  111.  
  112.         if text = startprefs then
  113.         do while ~eof(file)
  114.  
  115.             text = readln(file)
  116.             if text = endprefs then leave
  117.  
  118.         end
  119.         else if text = startsave then
  120.         do while ~eof(file)
  121.  
  122.             text = readln(file)
  123.             if text = endsave then leave
  124.  
  125.         end
  126.         else
  127.             startup = startup || cr || text
  128.  
  129.     end
  130.  
  131.     call close(file)
  132.  
  133. end
  134.  
  135. if exists(startupfile) then
  136. do
  137.     address command
  138.     'copy' startupfile startupfile".bak"
  139.     address
  140. end
  141.  
  142. selection   = ppm_SelectFromList("Select Settings to Save", 20, 9, 1, selection)
  143. if selection = '' then exit_msg()
  144.  
  145. /*    execute instructions at the end of list first >> SETUNITS    */
  146. selection = ppm_SortList(selection, 1, 0)
  147.  
  148. call ppm_ShowStatus("Working")
  149.  
  150. startup = startup || cr || startprefs || cr"call ppm_AutoUpdate(0)"cr
  151.  
  152. if pos('StyleTag', selection) ~= 0 then
  153. do
  154.     call ppm_SetBatchMode(1)
  155.     call ppm_SaveStyleTags(styletagdef) 
  156.  
  157.     startup = startup || cr || "call ppm_SetBatchMode(1)"
  158.     startup = startup || cr || "call ppm_LoadStyleTags('"styletagdef"')"
  159.     startup = startup || cr || "call ppm_SetBatchMode(0)"
  160.     call ppm_SetBatchMode(0)
  161.  
  162. end
  163.  
  164. if pos('ParaTag', selection) ~= 0 then
  165. do
  166.     call ppm_SetBatchMode(1)
  167.     call ppm_SaveParaTags(paratagdef) 
  168.  
  169.     startup = startup || cr || "call ppm_SetBatchMode(1)"
  170.     startup = startup || cr || "call ppm_LoadParaTags('"paratagdef"')"
  171.     startup = startup || cr || "call ppm_SetBatchMode(0)"
  172.     call ppm_SetBatchMode(0)
  173.  
  174. end
  175.  
  176. do while selection ~= ''
  177.  
  178.     parse var selection command '0a'x selection
  179.     command = strip(command)
  180.  
  181.     if command = '' then iterate
  182.  
  183.     interpret "setting = ppm_Get"command"()"
  184.  
  185.     if words(setting) > 1 & pos(upper(command), special) = 0 then
  186.         setting = separate(setting)
  187.     else if ~datatype(setting,n) then setting = '"'setting'"'
  188.  
  189.     command = "call ppm_Set"command"("setting")"
  190.  
  191.     startup = startup || cr || command
  192.  
  193. end
  194.  
  195. if ppm_Inform(2, "Would you like to save the default page?", "No", "Yes") then
  196. do
  197.     startup = startup || cr
  198.     startup = startup ||"call ppm_SetPageType(default,"||ppm_GetPageType(default)")"cr
  199.     startup = startup ||"call ppm_SetPageSize(default,"||separate(ppm_GetPageSize(default))")"cr
  200.     startup = startup ||"call ppm_SetPageMargins(default,"||separate(ppm_GetPageMargins(default))")"cr
  201.     startup = startup ||"call ppm_SetPageColumns(default,"||separate(ppm_GetPageColumns(default))")"cr
  202. end
  203.  
  204. startup = startup || cr"call ppm_AutoUpdate(1)"cr ||  endprefs
  205.  
  206. if ppm_Inform(2, "Would you like to have the AutoSave Genie run upon startup?", "No", "Yes") then
  207.     startup  = startup || cr||startsave||cr"address command"cr"'rx' 'rexx:AutoSave.pprx'"cr||endsave
  208.  
  209. if ~open(file, startupfile, "w") then exit_msg("Unable to open config file")
  210. call writeln(file, startup)
  211.  
  212. do i = 1 to clist
  213.     call writeln(file, clips.i)
  214. end
  215.  
  216. call close(file)
  217.  
  218. call ppm_ShowStatus("Done")
  219.  
  220. exit_msg()
  221.  
  222. separate:
  223. do
  224.     arg settings
  225.  
  226.     inpar   = ''
  227.  
  228.     do i = 1 to (words(settings) - 1)
  229.  
  230.         set     = word(settings, 1)
  231.  
  232.         inpar   = inpar||set","
  233.         settings    = subword(settings,2)
  234.  
  235.     end
  236.  
  237.     inpar = inpar||settings
  238.  
  239.     return(inpar)
  240.  
  241. end
  242.  
  243.  
  244. exit_msg:
  245. do
  246.  
  247.     arg message
  248.  
  249.     if message ~= '' then
  250.         call ppm_Inform(1, message,)
  251.  
  252.     call ppm_ClearStatus()
  253.     call ppm_AutoUpdate(1)
  254.     exit
  255.  
  256. end
  257.